package com.raulraja.model.persistence;

import com.raulraja.model.domain.PaginatedList;

import java.io.Serializable;


public interface PersistenceAdapter<Entity> {

	/**
	 * Returns a paginated list of all entities for this class
	 * @param entityClass the entity class
	 * @param start the start record
	 * @param limit the limit
	 * @return the list of matches
	 */
	PaginatedList<Entity> list(Class<Entity> entityClass, int start, int limit);

	/**
	 * Returns a paginated list of the selected property for this class
	 * @param entityClass the entity class
	 * @param start the start record
	 * @param limit the limit
	 * @return the list of matches
	 */
	PaginatedList<?> list(Class<Entity> entityClass, String property, int start, int limit);

    /**
     * Find a persistent object based on its unique id
     * @param entityClass the entity's class
     * @param id unique identifier
     * @return returns a persistent object
     */
    public Entity get(Class<Entity> entityClass, Serializable id);

    /**
     * Persists an object
     * @param entity to be persisted
	 * @return the saved entity
     */
    public Entity save(Entity entity);

    /**
     * Removes an entity from the data store
     * @param entity to be removed
	 * @return the deleted entity
     */
    public Entity delete(Entity entity);


}
